package com.wbcs.system.datatype;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.wbcs.config.database.type.AbsDatabaseType;

public class ByteType extends AbsDataType
{
    private final static Log log=LogFactory.getLog(ByteType.class);

    public Object getColumnValue(ResultSet rs,String column,AbsDatabaseType dbtype)
            throws SQLException
    {
        return Byte.valueOf(rs.getByte(column));
    }

    public Object getColumnValue(ResultSet rs,int iindex,AbsDatabaseType dbtype)
            throws SQLException
    {
        return Byte.valueOf(rs.getByte(iindex));
    }

    public void setPreparedStatementValue(int iindex,String value,PreparedStatement pstmt,
            AbsDatabaseType dbtype) throws SQLException
    {
        log.debug("setByte("+iindex+","+value+")");
        pstmt.setByte(iindex,(Byte)label2value(value));
    }

    
    
    
    

    public Class getJavaTypeClass()
    {
        return Byte.class;
    }

    public Object label2value(String label)
    {
        if(label==null||label.trim().equals("")) label="0";
        return Byte.valueOf(label.trim());
    }

}
